home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update17.zoo / util / diffs
Encoding:
Text File  |  1992-03-08  |  25.5 KB  |  1,166 lines

  1. *** 1.24    1992/01/14 19:49:15
  2. --- Changelog    1992/03/08 17:24:48
  3. ***************
  4. *** 254,256 ****
  5. --- 254,261 ----
  6.       use gnu-out.h instead of gnu-out.old.
  7.   
  8.   ----------------------------- Patchlevel 24 ---------------------------------
  9. + cplusdem.c:: ++jrb
  10. +     update C++ demangler for gcc 2.0
  11. + ----------------------------- Patchlevel 25 ---------------------------------
  12. *** 1.22    1992/01/14 19:47:11
  13. --- PatchLev.h    1992/03/08 17:24:49
  14. ***************
  15. *** 1,4 ****
  16. ! #define PatchLevel "24"
  17.   
  18.   /*
  19.    *    the Patch Level above is to identify the version
  20. --- 1,4 ----
  21. ! #define PatchLevel "25"
  22.   
  23.   /*
  24.    *    the Patch Level above is to identify the version
  25. *** 1.1    1991/07/23 22:43:21
  26. --- cplusdem.c    1992/03/08 17:24:51
  27. ***************
  28. *** 1,10 ****
  29.   /* Demangler for GNU C++ 
  30. !    Copyright (C) 1989 Free Software Foundation, Inc.
  31.      written by James Clark (jjc@jclark.uucp)
  32.      
  33.      This program is free software; you can redistribute it and/or modify
  34.      it under the terms of the GNU General Public License as published by
  35. !    the Free Software Foundation; either version 1, or (at your option)
  36.      any later version.
  37.   
  38.      This program is distributed in the hope that it will be useful,
  39. --- 1,10 ----
  40.   /* Demangler for GNU C++ 
  41. !    Copyright (C) 1989, 1992 Free Software Foundation, Inc.
  42.      written by James Clark (jjc@jclark.uucp)
  43.      
  44.      This program is free software; you can redistribute it and/or modify
  45.      it under the terms of the GNU General Public License as published by
  46. !    the Free Software Foundation; either version 2, or (at your option)
  47.      any later version.
  48.   
  49.      This program is distributed in the hope that it will be useful,
  50. ***************
  51. *** 19,31 ****
  52.   /* This is for g++ 1.36.1 (November 6 version). It will probably
  53.      require changes for any other version.
  54.   
  55. !    Modified for g++ 1.36.2 (November 18 version).  */
  56.   
  57.   /* This file exports one function
  58.   
  59.      char *cplus_demangle (const char *name)
  60. !    
  61. !    If `name' is a mangled function name produced by g++, then
  62.      a pointer to a malloced string giving a C++ representation
  63.      of the name will be returned; otherwise NULL will be returned.
  64.      It is the caller's responsibility to free the string which
  65. --- 19,35 ----
  66.   /* This is for g++ 1.36.1 (November 6 version). It will probably
  67.      require changes for any other version.
  68.   
  69. !    Modified for g++ 1.36.2 (November 18 version).
  70.   
  71. +    Modified for g++ 1.90.06 (December 31 version).
  72. +    Modified for g++ 1.95.03 (November 13 verison).  */
  73.   /* This file exports one function
  74.   
  75.      char *cplus_demangle (const char *name)
  76. !    If NAME is a mangled function name produced by GNU C++, then
  77.      a pointer to a malloced string giving a C++ representation
  78.      of the name will be returned; otherwise NULL will be returned.
  79.      It is the caller's responsibility to free the string which
  80. ***************
  81. *** 59,64 ****
  82. --- 63,75 ----
  83.   #define strrchr rindex
  84.   #endif
  85.   
  86. + /* This is '$' on systems where the assembler can deal with that.
  87. +    Where the assembler can't, it's '.' (but on many systems '.' is
  88. +    used for other things).  */
  89. + #if !defined (CPLUS_MARKER)
  90. + #define CPLUS_MARKER '$'
  91. + #endif
  92.   #ifndef __STDC__
  93.   #define const
  94.   #endif
  95. ***************
  96. *** 72,80 ****
  97. --- 83,93 ----
  98.   #ifdef __STDC__
  99.   extern char *xmalloc (int);
  100.   extern char *xrealloc (char *, int);
  101. + extern void free (char *);
  102.   #else
  103.   extern char *xmalloc ();
  104.   extern char *xrealloc ();
  105. + extern void free ();
  106.   #endif
  107.   
  108.   static char **typevec = 0;
  109. ***************
  110. *** 85,124 ****
  111.     const char *in;
  112.     const char *out;
  113.   } optable[] = {
  114. !   "new", " new",
  115. !   "delete", " delete",
  116. !   "ne", "!=",
  117. !   "eq", "==",
  118. !   "ge", ">=",
  119. !   "gt", ">",
  120. !   "le", "<=",
  121. !   "lt", "<",
  122. !   "plus", "+",
  123. !   "minus", "-",
  124. !   "mult", "*",
  125. !   "convert", "+",    /* unary + */
  126. !   "negate", "-",    /* unary - */
  127. !   "trunc_mod", "%",
  128. !   "trunc_div", "/",
  129. !   "truth_andif", "&&",
  130. !   "truth_orif", "||",
  131. !   "truth_not", "!",
  132. !   "postincrement", "++",
  133. !   "postdecrement", "--",
  134. !   "bit_ior", "|",
  135. !   "bit_xor", "^",
  136. !   "bit_and", "&",
  137. !   "bit_not", "~",
  138. !   "call", "()",
  139. !   "cond", "?:",
  140. !   "alshift", "<<",
  141. !   "arshift", ">>",
  142. !   "component", "->",
  143. !   "indirect", "*",
  144. !   "method_call", "->()",
  145. !   "addr", "&",        /* unary & */
  146. !   "array", "[]",
  147. !   "nop", "",            /* for operator= */
  148.   };
  149.   
  150.   /* Beware: these aren't '\0' terminated. */
  151. --- 98,171 ----
  152.     const char *in;
  153.     const char *out;
  154.   } optable[] = {
  155. !   "nw", " new",            /* new (1.92, ansi) */
  156. !   "dl", " delete",        /* new (1.92, ansi) */
  157. !   "new", " new",        /* old (1.91) */
  158. !   "delete", " delete",        /* old (1.91) */
  159. !   "ne", "!=",            /* old, ansi */
  160. !   "eq", "==",            /* old, ansi */
  161. !   "ge", ">=",            /* old, ansi */
  162. !   "gt", ">",            /* old, ansi */
  163. !   "le", "<=",            /* old, ansi */
  164. !   "lt", "<",            /* old, ansi */
  165. !   "plus", "+",            /* old */
  166. !   "pl", "+",            /* ansi */
  167. !   "apl", "+=",            /* ansi */
  168. !   "minus", "-",            /* old */
  169. !   "mi", "-",            /* ansi */
  170. !   "ami", "-=",            /* ansi */
  171. !   "mult", "*",            /* old */
  172. !   "ml", "*",            /* ansi */
  173. !   "aml", "*=",            /* ansi */
  174. !   "convert", "+",        /* old (unary +) */
  175. !   "negate", "-",        /* old (unary -) */
  176. !   "trunc_mod", "%",        /* old */
  177. !   "md", "%",            /* ansi */
  178. !   "amd", "%=",            /* ansi */
  179. !   "trunc_div", "/",        /* old */
  180. !   "dv", "/",            /* ansi */
  181. !   "adv", "/=",            /* ansi */
  182. !   "truth_andif", "&&",        /* old */
  183. !   "aa", "&&",            /* ansi */
  184. !   "truth_orif", "||",        /* old */
  185. !   "oo", "||",            /* ansi */
  186. !   "truth_not", "!",        /* old */
  187. !   "nt", "!",            /* ansi */
  188. !   "postincrement", "++",    /* old */
  189. !   "pp", "++",            /* ansi */
  190. !   "postdecrement", "--",    /* old */
  191. !   "mm", "--",            /* ansi */
  192. !   "bit_ior", "|",        /* old */
  193. !   "or", "|",            /* ansi */
  194. !   "aor", "|=",            /* ansi */
  195. !   "bit_xor", "^",        /* old */
  196. !   "er", "^",            /* ansi */
  197. !   "aer", "^=",            /* ansi */
  198. !   "bit_and", "&",        /* old */
  199. !   "ad", "&",            /* ansi */
  200. !   "aad", "&=",            /* ansi */
  201. !   "bit_not", "~",        /* old */
  202. !   "co", "~",            /* ansi */
  203. !   "call", "()",            /* old */
  204. !   "cl", "()",            /* ansi */
  205. !   "cond", "?:",            /* old */
  206. !   "alshift", "<<",        /* old */
  207. !   "ls", "<<",            /* ansi */
  208. !   "als", "<<=",            /* ansi */
  209. !   "arshift", ">>",        /* old */
  210. !   "rs", ">>",            /* ansi */
  211. !   "ars", ">>=",            /* ansi */
  212. !   "component", "->",        /* old */
  213. !   "rf", "->",            /* ansi */
  214. !   "indirect", "*",        /* old */
  215. !   "method_call", "->()",    /* old */
  216. !   "addr", "&",            /* old (unary &) */
  217. !   "array", "[]",        /* old */
  218. !   "vc", "[]",            /* ansi */
  219. !   "compound", ",",        /* old */
  220. !   "cm", ",",            /* ansi */
  221. !   "nop", "",            /* old (for operator=) */
  222. !   "as", "=",            /* ansi */
  223.   };
  224.   
  225.   /* Beware: these aren't '\0' terminated. */
  226. ***************
  227. *** 171,176 ****
  228. --- 218,246 ----
  229.   static void remember_type ();
  230.   #endif
  231.   
  232. + int
  233. + get_simple_count (type, res)
  234. +      char **type;
  235. +      int *res;
  236. + {
  237. +   int n = 0, success = 1;;
  238. +   
  239. +   do
  240. +     {
  241. +       n *= 10;
  242. +       n += **type - '0';
  243. +       *type += 1;
  244. +     } 
  245. +   while (isdigit (**type));
  246. +   if (strlen (*type) < n)
  247. +     {
  248. +       success = 0;
  249. +     }
  250. +   *res = n;
  251. +   return success;
  252. + }
  253.   char *
  254.   cplus_demangle (type)
  255.        const char *type;
  256. ***************
  257. *** 179,184 ****
  258. --- 249,256 ----
  259.     int n;
  260.     int success = 0;
  261.     int constructor = 0;
  262. +   int destructor = 0;
  263. +   int static_type = 0;
  264.     int const_flag = 0;
  265.     int i;
  266.     const char *p;
  267. ***************
  268. *** 198,225 ****
  269.     if (*p == '\0')
  270.       {
  271.         /* destructor */
  272. !       if (type[0] == '_' && type[1] == '$' && type[2] == '_')
  273.       {
  274. !       int n = (strlen (type) - 3)*2 + 3 + 2 + 1;
  275. !       char *tem = (char *) xmalloc (n);
  276. !       strcpy (tem, type + 3);
  277. !       strcat (tem, "::~");
  278. !       strcat (tem, type + 3);
  279. !       strcat (tem, "()");
  280. !       return tem;
  281.       }
  282.         /* static data member */
  283. !       if (*type != '_' && (p = strchr (type, '$')) != NULL)
  284.       {
  285. !       int n = strlen (type) + 2;
  286. !       char *tem = (char *) xmalloc (n);
  287. !       memcpy (tem, type, p - type);
  288. !       strcpy (tem + (p - type), "::");
  289. !       strcpy (tem + (p - type) + 2, p + 1);
  290. !       return tem;
  291.       }
  292. !       /* virtual table */
  293. !       if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$')
  294.       {
  295.         int n = strlen (type + 4) + 14 + 1;
  296.         char *tem = (char *) xmalloc (n);
  297. --- 270,288 ----
  298.     if (*p == '\0')
  299.       {
  300.         /* destructor */
  301. !       if (type[0] == '_' && type[1] == CPLUS_MARKER && type[2] == '_')
  302.       {
  303. !       destructor = 1;
  304. !       p = type;
  305.       }
  306.         /* static data member */
  307. !       else if (*type != '_' && (strchr (type, CPLUS_MARKER) != NULL))
  308.       {
  309. !       static_type = 1;
  310. !       p = type;
  311.       }
  312. !       /* virtual table "_vt$"  */
  313. !       else if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == CPLUS_MARKER)
  314.       {
  315.         int n = strlen (type + 4) + 14 + 1;
  316.         char *tem = (char *) xmalloc (n);
  317. ***************
  318. *** 227,252 ****
  319.         strcat (tem, " virtual table");
  320.         return tem;
  321.       }
  322. !       return NULL;
  323.       }
  324.   
  325.     string_init (&decl);
  326.   
  327. !   if (p == type)
  328.       {
  329. !       if (!isdigit (p[2]))
  330.       {
  331.         string_delete (&decl);
  332.         return NULL;
  333.       }
  334. !       constructor = 1;
  335.       }
  336.     else
  337.       {
  338.         string_appendn (&decl, type, p - type);
  339.         munge_function_name (&decl);
  340.       }
  341. -   p += 2;
  342.   
  343.   #ifndef LONGERNAMES
  344.     premangle = p;
  345. --- 290,348 ----
  346.         strcat (tem, " virtual table");
  347.         return tem;
  348.       }
  349. !       else return NULL;
  350.       }
  351.   
  352.     string_init (&decl);
  353.   
  354. !   if (static_type)
  355. !     {
  356. !       if (!isdigit (p[0]) && ('t' != p[0]))
  357. !     {
  358. !       string_delete (&decl);
  359. !       return NULL;
  360. !     }
  361. !     }
  362. !   else if (destructor)
  363.       {
  364. !       if (!isdigit (p[3])&& ('t' != p[3]))
  365.       {
  366.         string_delete (&decl);
  367.         return NULL;
  368.       }
  369. !       p += 3;
  370. !     }
  371. !   else if (p == type)
  372. !     {
  373. !       if (!isdigit (p[2]) && ('t' != p[2]))
  374. !     {
  375. !       p += 1;
  376. !       while (*p != '\0' && !(*p == '_' && p[1] == '_'))
  377. !         p++;
  378. !       string_appendn (&decl, type, p - type);      
  379. !       string_appendn (&decl, "", 1);
  380. !       munge_function_name (&decl);
  381. !       if (decl.b[0] == '_')
  382. !         {
  383. !           string_delete (&decl);
  384. !           return NULL;
  385. !         }
  386. !       else
  387. !         p += 2;
  388. !     }
  389. !       else
  390. !     {
  391. !       constructor = 1;
  392. !       p += 2;
  393. !     }
  394.       }
  395.     else
  396.       {
  397.         string_appendn (&decl, type, p - type);
  398. +       decl.p[0] = '0';
  399.         munge_function_name (&decl);
  400. +       p += 2;
  401.       }
  402.   
  403.   #ifndef LONGERNAMES
  404.     premangle = p;
  405. ***************
  406. *** 286,295 ****
  407.         string_delete (&decl);
  408.         return NULL;
  409.       }
  410. !       if (constructor)
  411.       {
  412.         string_appendn (&decl, p, n);
  413.         string_append (&decl, "::");
  414.         string_appendn (&decl, p, n);
  415.       }
  416.         else
  417. --- 382,393 ----
  418.         string_delete (&decl);
  419.         return NULL;
  420.       }
  421. !       if (constructor || destructor)
  422.       {
  423.         string_appendn (&decl, p, n);
  424.         string_append (&decl, "::");
  425. +       if (destructor)
  426. +         string_append(&decl, "~");
  427.         string_appendn (&decl, p, n);
  428.       }
  429.         else
  430. ***************
  431. *** 301,307 ****
  432.   #ifndef LONGERNAMES
  433.         remember_type (premangle, p - premangle);
  434.   #endif
  435. !       success = do_args (&p, &decl);
  436.         if (const_flag)
  437.       string_append (&decl, " const");
  438.         break;
  439. --- 399,412 ----
  440.   #ifndef LONGERNAMES
  441.         remember_type (premangle, p - premangle);
  442.   #endif
  443. !       if (static_type)
  444. !     {
  445. !       string_append(&decl, p+1);
  446. !       p += strlen(p);
  447. !       success = 1;
  448. !     }
  449. !       else
  450. !     success = do_args (&p, &decl);
  451.         if (const_flag)
  452.       string_append (&decl, " const");
  453.         break;
  454. ***************
  455. *** 309,314 ****
  456. --- 414,609 ----
  457.         p += 1;
  458.         success = do_args (&p, &decl);
  459.         break;
  460. +     /* template additions */
  461. +     case 't':
  462. +       p += 1;
  463. +       {
  464. +     int r, i;
  465. +     int non_empty = 0;
  466. +     string tname;
  467. +     string trawname;
  468. +     
  469. +     string temp;
  470. +     int need_comma = 0;
  471. +     
  472. +     string_init(&tname);
  473. +     string_init(&trawname);
  474. +     
  475. +     /* get template name */
  476. +     if (!get_simple_count (&p, &r))
  477. +       {
  478. +         string_delete (&decl);
  479. +         return 0;
  480. +       }
  481. +     string_appendn (&tname, p, r);
  482. +     string_appendn (&trawname, p, r);
  483. +     string_appendn (&trawname, "", 1);
  484. +     p += r;
  485. +     string_append (&tname, "<");
  486. +     /* get size of template parameter list */
  487. +     if (!get_count (&p, &r))
  488. +       return 0;
  489. +     for (i = 0; i < r; i++)
  490. +       {
  491. +         if (need_comma)
  492. +           string_append (&tname, ", ");
  493. +         /* Z for type parameters */
  494. +         if (*p == 'Z')
  495. +           {
  496. +         p += 1;
  497. +         
  498. +         success = do_type (&p, &temp);
  499. +         string_appendn (&temp, "", 1);
  500. +         if (success)
  501. +           string_append (&tname, temp.b);
  502. +         string_delete(&temp);
  503. +         if (!success)
  504. +           break;
  505. +           }
  506. +         /* otherwise, value parameter */
  507. +         else
  508. +           {
  509. +         const char *old_p  = p;
  510. +         int is_pointer = 0;
  511. +         int is_real = 0;
  512. +         int is_integral = 0;
  513. +         int done = 0;
  514. +         success = do_type (&p, &temp);
  515. +         string_appendn (&temp, "", 1);
  516. +         if (success)
  517. +           string_append (&tname, temp.b);
  518. +         string_delete(&temp);
  519. +         if (!success)
  520. +           break;
  521. +         string_append (&tname, "=");
  522. +         while (*old_p && !done)
  523. +           {    
  524. +             switch (*old_p)
  525. +               {
  526. +               case 'P':
  527. +               case 'R':
  528. +             done = is_pointer = 1;
  529. +             break;
  530. +               case 'C':    /* const */
  531. +               case 'U':    /* unsigned */
  532. +               case 'V':    /* volatile */
  533. +               case 'F':    /* function */
  534. +               case 'M':    /* member function */
  535. +               case 'O':    /* ??? */
  536. +             old_p++;
  537. +             continue;
  538. +               case 'Q':    /* repetition of following */
  539. +               case 'T':    /* remembered type */
  540. +             abort();
  541. +             break;
  542. +               case 'v':    /* void */
  543. +             abort();
  544. +             break;
  545. +               case 'x':    /* long long */
  546. +               case 'l':    /* long */
  547. +               case 'i':    /* int */
  548. +               case 's':    /* short */
  549. +               case 'c':    /* char */
  550. +             done = is_integral = 1;
  551. +             break;
  552. +               case 'r':    /* long double */
  553. +               case 'd':    /* double */
  554. +               case 'f':    /* float */
  555. +             done = is_real = 1;
  556. +             break;
  557. +               default:
  558. +             abort();
  559. +               }
  560. +           }
  561. +         if (is_integral)
  562. +           {
  563. +             if (*p == 'm')
  564. +               {
  565. +             string_appendn (&tname, "-", 1);
  566. +             p++;
  567. +               }
  568. +             while (isdigit (*p))    
  569. +               {
  570. +             string_appendn (&tname, p, 1);
  571. +             p++;
  572. +               }
  573. +           }
  574. +         else if (is_real)
  575. +           {
  576. +             if (*p == 'm')
  577. +               {
  578. +             string_appendn (&tname, "-", 1);
  579. +             p++;
  580. +               }
  581. +             while (isdigit (*p))    
  582. +               {
  583. +             string_appendn (&tname, p, 1);
  584. +             p++;
  585. +               }
  586. +             if (*p == '.') /* fraction */
  587. +               {
  588. +             string_appendn (&tname, ".", 1);
  589. +             p++;
  590. +             while (isdigit (*p))    
  591. +               {
  592. +                 string_appendn (&tname, p, 1);
  593. +                 p++;
  594. +               }
  595. +               }
  596. +             if (*p == 'e') /* exponent */
  597. +               {
  598. +             string_appendn (&tname, "e", 1);
  599. +             p++;
  600. +             while (isdigit (*p))    
  601. +               {
  602. +                 string_appendn (&tname, p, 1);
  603. +                 p++;
  604. +               }
  605. +               }
  606. +           }
  607. +         else if (is_pointer)
  608. +           {
  609. +             int symbol_len;
  610. +             
  611. +             if (!get_count (&p, &symbol_len))
  612. +               {
  613. +             success = 0;
  614. +             break;
  615. +               }
  616. +             string_appendn (&tname, p, symbol_len);
  617. +             p += symbol_len;
  618. +           }
  619. +           }
  620. +         need_comma = 1;
  621. +       }
  622. +     string_append (&tname, ">::");
  623. +     if (destructor)
  624. +       string_append(&tname, "~");
  625. +     if (constructor || destructor) {
  626. +       string_appendn (&trawname, "", 1);
  627. +       string_append (&tname, trawname.b);
  628. +     }
  629. +     string_delete(&trawname);
  630. +     
  631. +     if (!success) {
  632. +       string_delete(&tname);
  633. +       return 0;
  634. +     }
  635. +     string_appendn (&tname, "", 1);
  636. +     string_prepend (&decl, tname.b);
  637. +     string_delete (&tname);
  638. +     if (static_type)
  639. +       {
  640. +         string_append (&decl, p+1);
  641. +         p += strlen (p);
  642. +         success = 1;
  643. +       }
  644. +     else
  645. +       success = do_args (&p, &decl);
  646. +     break;
  647. +       }
  648.       }
  649.   
  650.     for (i = 0; i < ntypes; i++)
  651. ***************
  652. *** 343,349 ****
  653.       return 0;
  654.     *count = **type - '0';
  655.     *type += 1;
  656. !   /* see flush_repeats in cplus-method.c */
  657.     if (isdigit (**type))
  658.       {
  659.         const char *p = *type;
  660. --- 638,644 ----
  661.       return 0;
  662.     *count = **type - '0';
  663.     *type += 1;
  664. !   /* see flush_repeats in cp-method.c */
  665.     if (isdigit (**type))
  666.       {
  667.         const char *p = *type;
  668. ***************
  669. *** 388,393 ****
  670. --- 683,697 ----
  671.         int member;
  672.         switch (**type)
  673.       {
  674. +     case 'Q':
  675. +       n = (*type)[1] - '0';
  676. +       if (n < 0 || n > 9)
  677. +         success = 0;
  678. +       *type += 2;
  679. +       while (n-- > 0)
  680. +         do_type (type, result);
  681. +       break;
  682.       case 'P':
  683.         *type += 1;
  684.         string_prepend (&decl, "*");
  685. ***************
  686. *** 491,497 ****
  687.             string_append (&decl, " ");
  688.           else
  689.             non_empty = 1;
  690. !         string_append (&decl, "volatilep");
  691.             }
  692.           break;
  693.         }
  694. --- 795,801 ----
  695.             string_append (&decl, " ");
  696.           else
  697.             non_empty = 1;
  698. !         string_append (&decl, "volatile");
  699.             }
  700.           break;
  701.         }
  702. ***************
  703. *** 513,520 ****
  704.       }
  705.       }
  706.   
  707. -   done = 0;
  708.     non_empty = 0;
  709.     while (success && !done)
  710.       {
  711.         switch (**type)
  712. --- 817,856 ----
  713.       }
  714.       }
  715.   
  716.     non_empty = 0;
  717. +   if (success)
  718. +     success = do_cuv_prefix (type, result, &non_empty);
  719. +   if (success)
  720. +     success = do_builtin_type(type, result, &non_empty);
  721. +   
  722. +   if (success)
  723. +     {
  724. +       if (!string_empty (&decl))
  725. +     {
  726. +       string_append (result, " ");
  727. +       string_appends (result, &decl);
  728. +     }
  729. +       string_delete (&decl);
  730. +       return 1;
  731. +     }
  732. +   else
  733. +     {
  734. +       string_delete (&decl);
  735. +       string_delete (result);
  736. +       return 0;
  737. +     }
  738. + }
  739. + int
  740. + do_cuv_prefix (type, result, non_empty)
  741. +      char **type;
  742. +      string* result;
  743. +      int* non_empty;
  744. + {
  745. +   int success = 1;
  746. +   int done = 0;
  747. +   
  748.     while (success && !done)
  749.       {
  750.         switch (**type)
  751. ***************
  752. *** 521,546 ****
  753.       {
  754.       case 'C':
  755.         *type += 1;
  756. !       if (non_empty)
  757.           string_append (result, " ");
  758.         else
  759. !         non_empty = 1;
  760.         string_append (result, "const");
  761.         break;
  762.       case 'U':
  763.         *type += 1;
  764. !       if (non_empty)
  765.           string_append (result, " ");
  766.         else
  767. !         non_empty = 1;
  768.         string_append (result, "unsigned");
  769.         break;
  770.       case 'V':
  771.         *type += 1;
  772. !       if (non_empty)
  773.           string_append (result, " ");
  774.         else
  775. !         non_empty = 1;
  776.         string_append (result, "volatile");
  777.         break;
  778.       default:
  779. --- 857,882 ----
  780.       {
  781.       case 'C':
  782.         *type += 1;
  783. !       if (*non_empty)
  784.           string_append (result, " ");
  785.         else
  786. !         *non_empty = 1;
  787.         string_append (result, "const");
  788.         break;
  789.       case 'U':
  790.         *type += 1;
  791. !       if (*non_empty)
  792.           string_append (result, " ");
  793.         else
  794. !         *non_empty = 1;
  795.         string_append (result, "unsigned");
  796.         break;
  797.       case 'V':
  798.         *type += 1;
  799. !       if (*non_empty)
  800.           string_append (result, " ");
  801.         else
  802. !         *non_empty = 1;
  803.         string_append (result, "volatile");
  804.         break;
  805.       default:
  806. ***************
  807. *** 548,671 ****
  808.         break;
  809.       }
  810.       }
  811. !   if (success)
  812. !     switch (**type)
  813. !       {
  814. !       case '\0':
  815. !       case '_':
  816. !     break;
  817. !       case 'v':
  818. !     *type += 1;
  819. !     if (non_empty)
  820. !       string_append (result, " ");
  821. !     string_append (result, "void");
  822. !     break;
  823. !       case 'x':
  824. !     *type += 1;
  825. !     if (non_empty)
  826. !       string_append (result, " ");
  827. !     string_append (result, "long long");
  828. !     break;
  829. !       case 'l':
  830. !     *type += 1;
  831. !     if (non_empty)
  832. !       string_append (result, " ");
  833. !     string_append (result, "long");
  834. !     break;
  835. !       case 'i':
  836. !     *type += 1;
  837. !     if (non_empty)
  838. !       string_append (result, " ");
  839. !     string_append (result, "int");
  840. !     break;
  841. !       case 's':
  842. !     *type += 1;
  843. !     if (non_empty)
  844. !       string_append (result, " ");
  845. !     string_append (result, "short");
  846. !     break;
  847. !       case 'c':
  848. !     *type += 1;
  849. !     if (non_empty)
  850. !       string_append (result, " ");
  851. !     string_append (result, "char");
  852. !     break;
  853. !       case 'r':
  854. !     *type += 1;
  855. !     if (non_empty)
  856. !       string_append (result, " ");
  857. !     string_append (result, "long double");
  858. !     break;
  859. !       case 'd':
  860. !     *type += 1;
  861. !     if (non_empty)
  862. !       string_append (result, " ");
  863. !     string_append (result, "double");
  864. !     break;
  865. !       case 'f':
  866. !     *type += 1;
  867. !     if (non_empty)
  868. !       string_append (result, " ");
  869. !     string_append (result, "float");
  870. !     break;
  871. !       case 'G':
  872. !     *type += 1;
  873. !     if (!isdigit (**type))
  874. !       {
  875. !         success = 0;
  876. !         break;
  877. !       }
  878. !     /* fall through */
  879. !       case '0':
  880. !       case '1':
  881. !       case '2':
  882. !       case '3':
  883. !       case '4':
  884. !       case '5':
  885. !       case '6':
  886. !       case '7':
  887. !       case '8':
  888. !       case '9':
  889. !     n = 0;
  890. !     do
  891. !       {
  892. !         n *= 10;
  893. !         n += **type - '0';
  894. !         *type += 1;
  895. !       }
  896. !     while (isdigit (**type));
  897. !     if (strlen (*type) < n)
  898. !       {
  899. !         success = 0;
  900. !         break;
  901. !       }
  902. !     if (non_empty)
  903. !       string_append (result, " ");
  904. !     string_appendn (result, *type, n);
  905. !     *type += n;
  906. !     break;
  907. !       default:
  908. !     success = 0;
  909. !     break;
  910. !       }
  911.   
  912. !   if (success)
  913.       {
  914. !       if (!string_empty (&decl))
  915.       {
  916. !       string_append (result, " ");
  917. !       string_appends (result, &decl);
  918.       }
  919. !       string_delete (&decl);
  920. !       return 1;
  921. !     }
  922. !   else
  923. !     {
  924. !       string_delete (&decl);
  925. !       string_delete (result);
  926. !       return 0;
  927.       }
  928.   }
  929.   
  930.   /* `result' will be initialised in do_type; it will be freed on failure */
  931. --- 884,1001 ----
  932.         break;
  933.       }
  934.       }
  935. !   return success;
  936. ! }
  937.   
  938. ! int
  939. ! do_builtin_type (type, result, non_empty)
  940. !      char **type;
  941. !      string* result;
  942. !      int *non_empty;
  943. ! {
  944. !   int success = 1;
  945. !   int n;
  946. !   
  947. !   switch (**type)
  948.       {
  949. !     case '\0':
  950. !     case '_':
  951. !       break;
  952. !     case 'v':
  953. !       *type += 1;
  954. !       if (*non_empty)
  955. !     string_append (result, " ");
  956. !       string_append (result, "void");
  957. !       break;
  958. !     case 'x':
  959. !       *type += 1;
  960. !       if (*non_empty)
  961. !     string_append (result, " ");
  962. !       string_append (result, "long long");
  963. !       break;
  964. !     case 'l':
  965. !       *type += 1;
  966. !       if (*non_empty)
  967. !     string_append (result, " ");
  968. !       string_append (result, "long");
  969. !       break;
  970. !     case 'i':
  971. !       *type += 1;
  972. !       if (*non_empty)
  973. !     string_append (result, " ");
  974. !       string_append (result, "int");
  975. !       break;
  976. !     case 's':
  977. !       *type += 1;
  978. !       if (*non_empty)
  979. !     string_append (result, " ");
  980. !       string_append (result, "short");
  981. !       break;
  982. !     case 'c':
  983. !       *type += 1;
  984. !       if (*non_empty)
  985. !     string_append (result, " ");
  986. !       string_append (result, "char");
  987. !       break;
  988. !     case 'r':
  989. !       *type += 1;
  990. !       if (*non_empty)
  991. !     string_append (result, " ");
  992. !       string_append (result, "long double");
  993. !       break;
  994. !     case 'd':
  995. !       *type += 1;
  996. !       if (*non_empty)
  997. !     string_append (result, " ");
  998. !       string_append (result, "double");
  999. !       break;
  1000. !     case 'f':
  1001. !       *type += 1;
  1002. !       if (*non_empty)
  1003. !     string_append (result, " ");
  1004. !       string_append (result, "float");
  1005. !       break;
  1006. !     case 'G':
  1007. !       *type += 1;
  1008. !       if (!isdigit (**type))
  1009.       {
  1010. !       success = 0;
  1011. !       break;
  1012.       }
  1013. !       /* fall through */
  1014. !     case '0':
  1015. !     case '1':
  1016. !     case '2':
  1017. !     case '3':
  1018. !     case '4':
  1019. !     case '5':
  1020. !     case '6':
  1021. !     case '7':
  1022. !     case '8':
  1023. !     case '9':
  1024. !       n = 0;
  1025. !       do
  1026. !     {
  1027. !       n *= 10;
  1028. !       n += **type - '0';
  1029. !       *type += 1;
  1030. !     }
  1031. !       while (isdigit (**type));
  1032. !       if (strlen (*type) < n)
  1033. !     {
  1034. !       success = 0;
  1035. !       break;
  1036. !     }
  1037. !       if (*non_empty)
  1038. !     string_append (result, " ");
  1039. !       string_appendn (result, *type, n);
  1040. !       *type += n;
  1041. !       break;
  1042. !     default:
  1043. !       success = 0;
  1044. !       break;
  1045.       }
  1046. +   return success;
  1047.   }
  1048.   
  1049.   /* `result' will be initialised in do_type; it will be freed on failure */
  1050. ***************
  1051. *** 773,780 ****
  1052.   munge_function_name (name)
  1053.        string *name;
  1054.   {
  1055. !   if (!string_empty (name) && name->p - name->b >= 3 
  1056. !       && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$')
  1057.       {
  1058.         int i;
  1059.         /* see if it's an assignment expression */
  1060. --- 1103,1113 ----
  1061.   munge_function_name (name)
  1062.        string *name;
  1063.   {
  1064. !   if (string_empty (name))
  1065. !     return;
  1066. !   if (name->p - name->b >= 3 
  1067. !       && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == CPLUS_MARKER)
  1068.       {
  1069.         int i;
  1070.         /* see if it's an assignment expression */
  1071. ***************
  1072. *** 812,819 ****
  1073.       }
  1074.         return;
  1075.       }
  1076. !   else if (!string_empty (name) && name->p - name->b >= 5
  1077. !        && memcmp (name->b, "type$", 5) == 0)
  1078.       {
  1079.         /* type conversion operator */
  1080.         string type;
  1081. --- 1145,1151 ----
  1082.       }
  1083.         return;
  1084.       }
  1085. !   else if (name->p - name->b >= 5 && memcmp (name->b, "type$", 5) == 0)
  1086.       {
  1087.         /* type conversion operator */
  1088.         string type;
  1089. ***************
  1090. *** 825,830 ****
  1091. --- 1157,1215 ----
  1092.         string_appends (name, &type);
  1093.         string_delete (&type);
  1094.         return;
  1095. +     }
  1096. +     }
  1097. +   /* ANSI.  */
  1098. +   else if (name->b[2] == 'o' && name->b[3] == 'p')
  1099. +     {
  1100. +       /* type conversion operator.  */
  1101. +       string type;
  1102. +       const char *tem = name->b + 4;
  1103. +       if (do_type (&tem, &type))
  1104. +     {
  1105. +       string_clear (name);
  1106. +       string_append (name, "operator ");
  1107. +       string_appends (name, &type);
  1108. +       string_delete (&type);
  1109. +       return;
  1110. +     }
  1111. +     }
  1112. +   else if (name->b[2] >= 'a' && name->b[2] <= 'z'
  1113. +        && name->b[3] >= 'a' && name->b[3] <= 'z')
  1114. +     {
  1115. +       int i;
  1116. +       if (name->b[4] == '\0')
  1117. +     {
  1118. +       /* Operator.  */
  1119. +       for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
  1120. +         {
  1121. +           if (strlen (optable[i].in) == 2
  1122. +           && memcmp (optable[i].in, name->b + 2, 2) == 0)
  1123. +         {
  1124. +           string_clear (name);
  1125. +           string_append (name, "operator");
  1126. +           string_append (name, optable[i].out);
  1127. +           return;
  1128. +         }
  1129. +         }
  1130. +     }
  1131. +       else
  1132. +     {
  1133. +       if (name->b[2] != 'a' || name->b[5] != '\0')
  1134. +         return;
  1135. +       /* Assignment.  */
  1136. +       for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++)
  1137. +         {
  1138. +           if (strlen (optable[i].in) == 3
  1139. +           && memcmp (optable[i].in, name->b + 2, 3) == 0)
  1140. +         {
  1141. +           string_clear (name);
  1142. +           string_append (name, "operator");
  1143. +           string_append (name, optable[i].out);
  1144. +           return;
  1145. +         }
  1146. +         }
  1147.       }
  1148.       }
  1149.   }
  1150.